package com.example.lenovo.appstore.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.lenovo.appstore.R;
import com.example.lenovo.model.CategoryListModel;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

/**
 * 作者：tb on 2019/3/13.
 * 邮箱：
 * 版本：
 */

public class CartUpdateListAdapter extends RecyclerView.Adapter<CartUpdateListAdapter.ViewHolder> {

    private Context context;
    private List<CategoryListModel.CategoryList> data;

    public CartUpdateListAdapter(Context context, List<CategoryListModel.CategoryList> data) {
        this.context = context;
        this.data = data;

    }

    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_cart, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
//        holder.name.setText(data.get(position).getName());
//        Glide.with(context).load(URL.baseURL + data.get(position).getImg()).into(holder.icon);
        holder.hot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent = new Intent(context, SListActivity.class);
//                intent.putExtra("id", data.get(position).getC_id() + "");
//                context.startActivity(intent);
            }
        });
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private TextView name;
        private ImageView icon;
        private RelativeLayout hot;

        public ViewHolder(View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.title);
            icon = itemView.findViewById(R.id.icon);
            hot = itemView.findViewById(R.id.gen);
        }
    }
}

